/*******************************************************************************
*   			Impacts of a Large-Scale Parenting Program: 				   *
*					Experimental Evidence from Chile						   *
********************************************************************************


	REQUIRES:	"${dt_final}panel_RR_indexes.dta"
				"${dt_final}baseline_sociodem_emp.dta"
				"${dt_final}follow_up_sociodem_emp.dta"
				"${dt_final}baseline_sociodem_oth.dta"
				
	CREATES:	${out_tables}/T5_takeup.xls
				
	WRITEN BY:  Italo Lopez  [italolop@usc.edu]

********************************************************************************
	Prepare data
*******************************************************************************/
	* Load Data 
	use "${dt_final}/panel_RR_indexes.dta", clear

/*******************************************************************************
*   Set macros for regressions
*******************************************************************************/
				

	* Controls
	*-----------------------------------------------------------
		macro  def Xvar1 "i.gender i.inc_qtaut_old i.pc_edu_mdsfin hh_mem single num_hermen"  	
		macro  def Xvar2 "i.age_year i.gender i.inc_qtaut_old i.pc_edu_mdsfin hh_mem single num_hermen active_old full_time_old"  	
		macro  def Xvar3 "i.age_year i.gender i.inc_qtaut_old i.pc_edu_mdsfin hh_mem single num_hermen active_old full_time_old active full_time"  	
		


	xtset CENTRO_SALUD

/*******************************************************************************
	Table A5: Table 5: Program take-up
*******************************************************************************/


	eststo fs1: xtreg treat2 group2 if x==1, fe i(CENTRO_SALUD)
	eststo fs2: xtreg treat2 group2 $Xvar2 if x==1, fe i(CENTRO_SALUD)

	eststo fs4: xtreg treat3 group3 if x==1, fe i(CENTRO_SALUD)
	eststo fs5: xtreg treat3 group3 $Xvar2 if x==1, fe i(CENTRO_SALUD)

	esttab fs* using  "${out_tables}/T5_takeup.csv", replace f 					/*
			*/ cells("b(fmt(3)star)" "se(fmt(3)par)")  							/*
			*/ star(* 0.10 ** 0.05 *** 0.01) 									/*  
			*/ stats(r2  N , fmt(2 0 ) labels("R-squared" "Observations" ))     /*
			*/ varlabels(group2 "NEP-B" group3 "NEP-I") keep(group2 group3)     /*
			*/ mtitles("Participation NEP-B""Participation NEP-B" 			    /*
			*/ "Participation NEP-I""Participation NEP-1" ) legend
			

 

